//
//  YWHeaderVideoListCell.m
//  videoTest3
//
//  Created by jun peng on 2022/6/21.
//

#import "YWHeaderVideoListCell.h"

@interface YWHeaderVideoListCell ()
@property (weak, nonatomic) IBOutlet UIView *bgView;
@property (weak, nonatomic) IBOutlet UIImageView *iconView;
@property (weak, nonatomic) IBOutlet UIView *gradiView;

@property(nonatomic,weak) CAGradientLayer * gradientLayer;

@end

@implementation YWHeaderVideoListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.bgView.layer.cornerRadius = 5;
    self.iconView.layer.cornerRadius = 5;
    self.iconView.clipsToBounds = YES;
    
    CAGradientLayer * gradientLayer = [CAGradientLayer layer];
//               self.gradientLayer = gradientLayer;
    gradientLayer.colors = @[(__bridge id)YWColorRGBA(0, 0, 100, 0.4).CGColor,(__bridge id)[UIColor clearColor].CGColor];
    gradientLayer.startPoint = CGPointMake(0, 1);
    gradientLayer.endPoint = CGPointMake(0, 0);
    gradientLayer.locations = @[@0,@1];
    [self.gradiView.layer addSublayer:gradientLayer];
    self.gradientLayer = gradientLayer;
    
}

-(void)layoutSubviews{
    [super layoutSubviews];
    
    self.gradientLayer.frame = self.gradiView.bounds;
}

-(void)setStatus:(YWGetNewsDataStatus *)status{
    _status = status;
    
    if (status.isSelect == YES) {
        self.bgView.backgroundColor = [UIColor systemBlueColor];
        self.gradiView.hidden = NO;
    }
    else{
        
        self.bgView.backgroundColor = [UIColor whiteColor];
        self.gradiView.hidden = YES;
    }
    
    [self.iconView sd_setImageWithURL:[NSURL URLWithString:status.Img] placeholderImage:[UIImage imageWithColor:YWColor(240, 240, 240)]];
   
    
    
}

@end
